#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtNetwork>
#include <QSystemTrayIcon>
#include <QSettings>
#include <QListWidgetItem>
#include "LutController.h"
#include "User.h"

class DiscussPane;

namespace Ui {
	class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
	~MainWindow();

	void sendMsg(QString str);
	void sendPrivateMsg(int to, QString str);

	int myId();

	void initMainWindow();

	bool getShowTime();

private:
	Ui::MainWindow *ui;

	QTcpSocket *sock;

	QString nickname;
	int id;

	QSystemTrayIcon *trayIcon;
	QIcon *icon;
	QIcon *iconWarn;
	bool event ( QEvent * event );
	DiscussPane *findPaneById(int id);

	void majUserList(QStringList list);
	void majUser(QString data);

	bool notifications;
	bool showTime;

	QSettings settings;

	DiscussPane *mainPane;
	QList<DiscussPane*> *privatePanes;

	QString serverIP;
	int serverPort;

	QAction *exitAct;
	QMenu *menuTray;

private slots:
	void on_actionClear_triggered();
	void on_actionShow_time_toggled(bool v);
	void on_actionShow_time_triggered();
	void on_actionClose_current_tab_triggered();
	void on_actionNotifications_toggled(bool v);
	void on_actionChange_server_triggered();
	void on_actionChange_nickname_triggered();
	void onExitAct();
	void onTrayClicked(QSystemTrayIcon::ActivationReason r);
	void errorReceived(QAbstractSocket::SocketError socketError);
	void onConnected();

	void dataHandler();
	void onItemDoubleClicked(QModelIndex index);
	void onTabChanged(int id);

	void onToRead(DiscussPane *p);

};

#endif // MAINWINDOW_H
